import ctypes
import ctypes.wintypes
import sys
user32 = ctypes.windll.user32

def LowLevelMouseProc(nCode, wParam, lParam):
  
  if wParam == 513:
    print("Left button pressed")
  elif wParam == 0x0204:
    print("Right button pressed")
  return user32.CallNextHookEx(0, nCode, ctypes.wintypes.WPARAM(wParam), ctypes.wintypes.LPARAM( lParam))


def main():
  LRESULT = ctypes.c_long
  MYCFUNC = ctypes.CFUNCTYPE(LRESULT,ctypes.wintypes.INT,ctypes.wintypes.WPARAM,ctypes.wintypes.LPARAM)
  CFIMCP = MYCFUNC(LowLevelMouseProc)
  hook_id = user32.SetWindowsHookExW(14,CFIMCP,None,0)
  msg = ctypes.wintypes.MSG()
  while user32.GetMessageW(ctypes.byref(msg),None,0,0) != 0:
    user32.TranslateMessage(msg)
    user32.DispatchMessageW(msg)

if __name__ == '__main__':
  main()
